package com.xm9m.web.service.utils;

import java.util.Random;

/**
 * Created by 123 on 2016/1/18.
 */
public class GenerateNick {


    private static final int LENGTH = 8;


    public static String generate() {
        String no="";
        int num[]=new int[LENGTH];
        int c=0;
        for (int i = 0; i < LENGTH; i++) {
            num[i] = new Random().nextInt(10);
            c = num[i];
            for (int j = 0; j < i; j++) {
                if (num[j] == c) {
                    i--;
                    break;
                }
            }
        }
        if (num.length>0) {
            for (int i = 0; i < num.length; i++) {
                no+=num[i];
            }
        }
        return no;
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {

            System.out.println(generate());
        }
    }
}
